﻿Imports Microsoft.VisualBasic
Imports System.Data

<System.ComponentModel.DataObjectAttribute(True)> _
Public Class BLL_QueryTrainingCourse

    Public Sub New()
        ' 
        ' TODO: 在此加入建構函式的程式碼 
        ' 
    End Sub

    'SELECT 
    <System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.[Select])> _
    Public Function BLL_Select(ByVal GroupType As String) As DataTable

        Dim sql As New MyStringBuilder
        Dim dat As New clsData

        sql.AppendFormat("SELECT A.*, B.Text as CourseTypeText ")
        sql.AppendFormat("FROM TrainingCourse A ")
        sql.AppendFormat("inner join CodeMapping B on TableName='TrainingCourseGroup' and ColumnName='GroupType' and A.CourseType = B.Value ")
        sql.AppendFormat("WHERE A.CourseType ='{0}' or '{0}'='' ", GroupType)
        Return dat.GetData(sql)

    End Function

    'Delete 
    <System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete)> _
    Public Function BLL_Delete(ByVal original_Id As Integer) As Integer

        Dim sql As New MyStringBuilder
        Dim dat As New clsData

        sql.AppendFormat("DELETE TrainingCourse WHERE Id={0}", original_Id)

        dat.AccData(sql)
        Return 1

    End Function



End Class
